<% if session[:user_id] %>	
	<h1>Fuentes de alimentación disponibles</h1>

	<table border=1>
		<tr>
		  <th>Título</th>
		  <th>Descripcion</th>
		  <th>Conector ATX</th>
		  <th>Dimensiones</th>
		  <th>URL</th>
		  <th>Precio</th> 
		  <th></th>
		  <th></th>
		  <th></th>
		</tr>

	<% @powers.each do |power| %>
		<tr>
		  <td><%= power.title %></td>
		  <td><%= power.description %></td>
		  <td class="center"><%= power.atxconector %></td>
		  <td class="center"><%= power.dimensions %></td>
		  <td><%= link_to power.product_url, power.product_url, :target => '_blank' %></td>
		  <td class="center"><%= power.price %></td>
		  <td><%= link_to 'Mostrar', power %></td>
		  <td><%= link_to 'Editar', edit_power_path(power) %></td>
		  <td><%= link_to 'Eliminar', power, method: :delete, data: { confirm: '¿Está seguro?' } %></td>
		</tr>
	<% end %>
	</table>

	<br />

	<%= link_to 'Nueva fuente de alimentación', new_power_path %>
<% else %>
	<% if notice %>
	<p id="notice"><%= notice %></p>
	<% end %>

	<h1>Catalogo de fuentes de alimentacion</h1>

	<% @powers.each do |power| %>
		<div class="entry">
			<h3><%= power.title %></h3>
			<%= sanitize(power.description) %>
			<div class="price_line">
				<span class="price"><%= number_to_currency(power.price) %></span>
				<% prod = Product.find(:first, :conditions => ["heir_id = ? and heir_type = ?",power.id, 'Power']) %>
				<%= button_to 'Añadir a la configuracion', line_products_path(product_id: prod.id) %>
			</div>
		</div>
	<% end %>
<% end %>
